package com.asl.website.type.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.asl.common.annotation.Log;
import com.asl.common.core.controller.BaseController;
import com.asl.common.core.domain.AjaxResult;
import com.asl.common.enums.BusinessType;
import com.asl.website.type.domain.TTransportType;
import com.asl.website.type.service.ITTransportTypeService;
import com.asl.common.utils.poi.ExcelUtil;
import com.asl.common.core.page.TableDataInfo;

/**
 * 运输服务类型Controller
 * 
 * @author ruoyi
 * @date 2025-05-12
 */
@RestController
@RequestMapping("/type/type")
public class TTransportTypeController extends BaseController
{
    @Autowired
    private ITTransportTypeService tTransportTypeService;

    /**
     * 查询运输服务类型列表
     */
    @PreAuthorize("@ss.hasPermi('type:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTransportType tTransportType)
    {
        startPage();
        List<TTransportType> list = tTransportTypeService.selectTTransportTypeList(tTransportType);
        return getDataTable(list);
    }

    /**
     * 导出运输服务类型列表
     */
    @PreAuthorize("@ss.hasPermi('type:type:export')")
    @Log(title = "运输服务类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTransportType tTransportType)
    {
        List<TTransportType> list = tTransportTypeService.selectTTransportTypeList(tTransportType);
        ExcelUtil<TTransportType> util = new ExcelUtil<TTransportType>(TTransportType.class);
        util.exportExcel(response, list, "运输服务类型数据");
    }

    /**
     * 获取运输服务类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('type:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tTransportTypeService.selectTTransportTypeById(id));
    }

    /**
     * 新增运输服务类型
     */
    @PreAuthorize("@ss.hasPermi('type:type:add')")
    @Log(title = "运输服务类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTransportType tTransportType)
    {
        return toAjax(tTransportTypeService.insertTTransportType(tTransportType));
    }

    /**
     * 修改运输服务类型
     */
    @PreAuthorize("@ss.hasPermi('type:type:edit')")
    @Log(title = "运输服务类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTransportType tTransportType)
    {
        return toAjax(tTransportTypeService.updateTTransportType(tTransportType));
    }

    /**
     * 删除运输服务类型
     */
    @PreAuthorize("@ss.hasPermi('type:type:remove')")
    @Log(title = "运输服务类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tTransportTypeService.deleteTTransportTypeByIds(ids));
    }
}
